


#include<bits/stdc++.h>
using namespace std;

const int inf = 0x3f3f3f3f;
int main()
{
	int n, lx, rx, ly, ry;   
	cin >> n >> lx >> rx >> ly >> ry;     
	vector<int>a(n);
	vector<int>b(n);
	vector<int>c(n);     

	for (int i = 0; i < n; i++)cin >> c[i];
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++)cin >> b[i];

	int ret_max = -inf;
	int ret_min = inf;
	
		//枚举所有取值
		for (int x = lx; x <= rx; x++)
		{
			for (int y = ly; y <= ry; y++)
			{
				int sum = 0;
				for (int i = 0; i < n; i++) {
					int tmp = c[i] * pow(x, a[i]) * pow(y, b[i]);    
					sum += tmp;    
				}
				ret_max = max(ret_max, sum);    
				ret_min = min(ret_min, sum);  
			}
		}
		

	cout << ret_max << " " << ret_min << endl;    
	return 0;
}
